home *** CD-ROM | disk | FTP | other *** search
/ 1,000+ Great Games / 1_1000 Games.iso / DOSGAMES / BOGGLE.ZIP / SOURCE.ZIP / DICE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-03  |  1.1 KB  |  32 lines

  1. /*****************************************************************************
  2. * Program:  DICE.CPP
  3. * Purpose:  Handles the rolling of the dice and setting of the square letter
  4. *           based on the letters defined for that cube
  5. *****************************************************************************/
  6. #include  "bogwin.hpp"
  7. #include  "dice.hpp"
  8.  
  9. /*****************************************************************************
  10. * Function: Dice
  11. * Parms:    facestring - the sequence of letters defines for a particular die
  12. * Purpose:  Constructor
  13. * Returns:  Nothing
  14. *****************************************************************************/
  15. Dice::Dice(const char *facestring)
  16. {
  17.    for (int i=0; i<7; i++)
  18.       faces[i] = *facestring++;
  19. }
  20.  
  21. /*****************************************************************************
  22. * Function: Roll
  23. * Parms:    none
  24. * Purpose:  simulate the rolling of the dice
  25. * Returns:  a particular letter to show on the cube face
  26. *****************************************************************************/
  27. char *Dice::Roll()
  28. {
  29.    return( &faces[(rand() % 6)] );
  30. }
  31.  
  32.